<?php
/**
 * Created by PhpStorm.
 * User: mac
 * Date: 19/12/19
 * Time: 20:28
 */

namespace app\admin\controller;


use app\common\bean\ListMap;
use app\common\bean\SystemRechargeBean;
use app\common\controller\AdminController;
use app\common\manage\SystemRechargeManage;
use app\common\model\SystemRechargeModel;
use app\common\utils\ExitJsonUtil;

class Give extends AdminController
{
    /** 充值赠送列表
     * @return mixed
     * @throws \Exception
     */
    public function giveList(){
        $listMap = new ListMap();
        $listMap->setData($this->getParams);
        $contentMap = SystemRechargeManage::getInstance()->getPaginatorList($listMap);
        $this->assign("recharge",$contentMap->getList());
        $this->assign("currentPage",$contentMap->getCurrentPage());
        $this->assign("totalCount",$contentMap->getTotalCount());
        return $this->fetch();
    }

    /**管理充值数据
     * @return mixed
     * @throws \Exception
     */
    public function editGive(){
        if(request()->post()){
            $post = $this->postParams;
            $result = SystemRechargeModel::getInstance()->updateColumn(SystemRechargeBean::$id, $post[SystemRechargeBean::$id], $post['field'], $post['value']);
            ExitJsonUtil::getInstance()->exitData($result);
        }
        $giveList = SystemRechargeModel::getInstance()->selectData([],true);
        $this->assign('giveList',$giveList);
        return $this->fetch();
    }
}